'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 宝石
 * @author sundbcn@gmail.com (sun debing)
 */

var mongoose = require('mongoose');

///////////////////////////////////////////////////////////
/**
 * 宝石
 * @type {mongoose}
 */
var bagGemstoneSchema = new mongoose.Schema({
    // 宝石id
    gemstone_id: {
        type: Number,
        required: true,
        index: true
    },

    // 宝石类型
    gemstone_type: {
        type: Number,
        required: true
    },

    // 叠加个数
    stack_num: {
        type: Number,
        default: 1
    }
});

/**
 * 物品类型
 * @return {[type]} [description]
 */
bagGemstoneSchema.methods.getType = function () {
    return this.gemstone_type;
};

/**
 * 物品id
 * @return {[type]} [description]
 */
bagGemstoneSchema.methods.getId = function () {
    return this.gemstone_id;
};

/**
 * 叠加的数量
 */
bagGemstoneSchema.methods.getStackNum = function () {
    return this.stack_num;
};

/**
 * 添加叠加的数量
 */
bagGemstoneSchema.methods.addStackNum = function () {
    this.stack_num++;
};

/**
 * 减少叠加的数量
 */
bagGemstoneSchema.methods.subStackNum = function () {
    this.stack_num--;
};

if (!bagGemstoneSchema.options.toJSON) {
    bagGemstoneSchema.options.toJSON = {};
}
/* jshint unused:false */
bagGemstoneSchema.options.toJSON.transform = function (doc, ret) {
    delete ret._id;
};

module.exports = bagGemstoneSchema;
